package pl.cvplus.entity;

import javax.persistence.*;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: Piotrek
 * Date: 02.03.12
 * Time: 23:16
 * To change this template use File | Settings | File Templates.
 */
@javax.persistence.Table(name = "cp_personal_data", schema = "public", catalog = "")
@Entity
public class CpPersonalData {
    private Integer id;

    @javax.persistence.Column(name = "id", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Id
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    private String firstname;

    @javax.persistence.Column(name = "firstname", nullable = true, insertable = true, updatable = true, length = 20, precision = 0)
    @Basic
    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    private String surname;

    @javax.persistence.Column(name = "surname", nullable = true, insertable = true, updatable = true, length = 30, precision = 0)
    @Basic
    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    private String email;

    @javax.persistence.Column(name = "email", nullable = true, insertable = true, updatable = true, length = 50, precision = 0)
    @Basic
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    private Integer languagePk;

    @javax.persistence.Column(name = "language_pk", nullable = false, insertable = true, updatable = true, length = 10, precision = 0)
    @Basic
    public Integer getLanguagePk() {
        return languagePk;
    }

    public void setLanguagePk(Integer languagePk) {
        this.languagePk = languagePk;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        CpPersonalData that = (CpPersonalData) o;

        if (email != null ? !email.equals(that.email) : that.email != null) return false;
        if (firstname != null ? !firstname.equals(that.firstname) : that.firstname != null) return false;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (languagePk != null ? !languagePk.equals(that.languagePk) : that.languagePk != null) return false;
        if (surname != null ? !surname.equals(that.surname) : that.surname != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (firstname != null ? firstname.hashCode() : 0);
        result = 31 * result + (surname != null ? surname.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (languagePk != null ? languagePk.hashCode() : 0);
        return result;
    }

    private Collection<CpCompanyData> cpCompanyDatasById;

    @OneToMany(mappedBy = "cpPersonalDataByOperatorFk")
    public Collection<CpCompanyData> getCpCompanyDatasById() {
        return cpCompanyDatasById;
    }

    public void setCpCompanyDatasById(Collection<CpCompanyData> cpCompanyDatasById) {
        this.cpCompanyDatasById = cpCompanyDatasById;
    }

    private CpLanguage cpLanguageByLanguagePk;

    @ManyToOne
    public
    @JoinColumn(name = "language_pk", referencedColumnName = "id", nullable = false)
    CpLanguage getCpLanguageByLanguagePk() {
        return cpLanguageByLanguagePk;
    }

    public void setCpLanguageByLanguagePk(CpLanguage cpLanguageByLanguagePk) {
        this.cpLanguageByLanguagePk = cpLanguageByLanguagePk;
    }
}
